<template>
	<div class="body_inner">

		<div class="info_change_page">
			<div class="page_top">
				<a href="/mypage"><i class="xi-arrow-left"></i></a>

				<div class="allMenu_btn" v-if="!allMenuShow" @click="allMenuShow = true">
					<div class="x"></div>
					<div class="y"></div>
					<div class="z"></div>
				</div>
				<div class="allMenu_btn open" v-if="allMenuShow" @click="allMenuShow = false">
					<div class="x coll rotate30 rotate45"></div>
					<div class="y coll" style="display: none;"></div>
					<div class="z coll rotate150 rotate135"></div>
				</div>
			</div>

			<div class="page_contents">
				<h3>
					정보수정
					<p>회원 정보를 입력해주세요 :&#41;</p>
				</h3>

				<form action="" class="form_boundary">
					<div>
						<p>이름</p>
						<input type="text" v-model="indeData.user_no" disabled>
					</div>

					<div>
						<p>이메일</p>
						<input type="email" v-model="indeData.email" disabled>
					</div>

					<div>
						<p>연락처</p>
						<input type="tel" v-model="indeData.phone">
					</div>

					<div>
						<p>출금주소</p>
						<input type="text" placeholder="자주 출금하시는 본인의 지갑주소를 입력하세요." v-model="indeData.address">
					</div>

					<p class="infoTxt">
						<i class="xi-info"></i>
						자주 출금하시는 주소를 등록해두시면 출금시 편리하게 사용하실 수 있습니다.
					</p>
					<p class="infoTxt">
						<i class="xi-info"></i>
						이메일과 전화번호는 중요정보로 변경을 원하실 경우 1:1문의를 보내주세요.
					</p>

					<div class="btn" @click="tijiao()">회원 정보 변경</div>
				</form>
			</div>
		</div>

		<nav id="allMenu" v-if="allMenuShow">
			<ul>
				<li>
					<a href="/main">
						<p><i class="xi-home"></i>홈</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/staking">
						<p><i class="xi-bank"></i>상품 구매</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/staking_sum">
						<p><i class="xi-credit-card"></i>상품 구매 합계</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/interest">
						<p><i class="xi-piggy-bank"></i>데일리내역</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/withdraw_apply">
						<p><i class="xi-money"></i>출금신청</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/withdraw_list">
						<p><i class="xi-wallet"></i>출금/송금내역</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/recommender">
						<p><i class="xi-group"></i>추천인 목록</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/mypage">
						<p><i class="xi-profile-o"></i>마이페이지</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>
			</ul>

			<div class="btn" @click="logout()">로그아웃</div>
		</nav>
	</div>
</template>
<script>
	import axios from "axios";
	export default {
		data() {
			return {
				showModel: false,
				indeData: {},
				is_master: null,
				accountList: [],
				next_account: '',
				allAccount: false,
				info: {
					is_master: null,
					max_proportion: null,
					next_account: "",
					now_proportion: 0,
					now_reward: "",
					now_reward_pdt: "",
					now_usdt: "",
					now_usdt_pdt: "",
					pdt: "",
					self_buy_price: "",
				},
				goodList: [],
				loading: false,
				withNum: '',
				address: '',
				loading: false,
				allMenuShow:false
			};
		},
		created() {},
		mounted() {
			this.getInfo();
		},
		methods: {
			getInfo() {
				var _this = this;
				axios.post('https://admintest.pdt-daily.com/api/index/index', {}, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'Access-Token': localStorage.getItem('token')
					}
				}).then(function(response) {
					console.log(response);
					if (response.data.status == 200) {
						_this.info = response.data.data.data;
						_this.accountList = response.data.data.list;
						_this.next_account = response.data.data.data.next_account;
						_this.is_master = response.data.data.data.is_master;
						_this.indeData = response.data.data.user_info;
					}
					if (response.data.status == 401) {
						_this.$router.push('/login');
					}
				}).catch(function(error) {
					console.log(error);
				});
			},
			tijiao() {
				var _this = this;
				axios.post('https://admintest.pdt-daily.com/api/user/update_info', {
					phone: _this.indeData.phone,
					address: _this.indeData.address
				}, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'Access-Token': localStorage.getItem('token')
					}
				}).then(function(response) {
					console.log(response);
					if (response.data.status == 200) {
						alert('수정 성공');
						return;
					}
				}).catch(function(error) {
					console.log(error);
				});
			},
			logout() {
				var _this = this;
				axios.post('https://admintest.pdt-daily.com/api/user/logout', {}, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'Access-Token': localStorage.getItem('token')
					}
				}).then(function(response) {
					console.log(response);
					if (response.data.status == 200) {
						alert('로그아웃 되었습니다.');
						localStorage.setItem('token', '');
						_this.$router.push('/login');
					}
				}).catch(function(error) {
					console.log(error);
				});
			}
		},
	};
</script>